| Conditions | 5 |
| Paths | 4 |
| Total Lines | 59 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | // BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. |
||
| 17 | $(document).on('turbolinks:load', function(){ |
||
| 18 | var controller = $("body").data('controller'); |
||
| 19 | var action = $("body").data('action'); |
||
| 20 | |||
| 21 | // Only run on the admins page. |
||
| 22 | if (controller == "admins" && action == "index") { |
||
| 23 | // show the modal with the correct form action url |
||
| 24 | $(".delete-user").click(function(data){ |
||
| 25 | var uid = $(data.target).closest("tr").data("user-uid") |
||
| 26 | var url = $("body").data("relative-root") |
||
| 27 | if (!url.endsWith("/")) { |
||
| 28 | url += "/" |
||
| 29 | } |
||
| 30 | url += "u/" + uid |
||
| 31 | $("#delete-confirm").parent().attr("action", url) |
||
| 32 | }) |
||
| 33 | |||
| 34 | $('.colorinput').ColorPicker({ |
||
| 35 | onHide: function (colpkr) { |
||
|
|
|||
| 36 | var colour = $("#user-colour").val(); |
||
| 37 | |||
| 38 | // Update the color in the database and reload the page |
||
| 39 | $.post($("#coloring-path").val(), {color: colour}).done(function(data) { |
||
| 40 | location.reload() |
||
| 41 | }); |
||
| 42 | }, |
||
| 43 | |||
| 44 | onSubmit: function(hsb, hex, rgb, el) { |
||
| 45 | $.post($("#coloring-path").val(), {color: '#' + hex}).done(function(data) { |
||
| 46 | location.reload() |
||
| 47 | }); |
||
| 48 | }, |
||
| 49 | |||
| 50 | onBeforeShow: function () { |
||
| 51 | var colour = $("#user-colour").val(); |
||
| 52 | |||
| 53 | $(this).ColorPickerSetColor(colour); |
||
| 54 | }, |
||
| 55 | |||
| 56 | onChange: function (hsb, hex, rgb) { |
||
| 57 | $('.colorinput span').css('backgroundColor', '#' + hex); |
||
| 58 | $("#user-colour").val('#' + hex); |
||
| 59 | } |
||
| 60 | }); |
||
| 61 | } |
||
| 62 | |||
| 63 | // Only run on the admins edit user page. |
||
| 64 | if (controller == "admins" && action == "edit_user") { |
||
| 65 | $(".setting-btn").click(function(data){ |
||
| 66 | var url = $("body").data("relative-root") |
||
| 67 | if (!url.endsWith("/")) { |
||
| 68 | url += "/" |
||
| 69 | } |
||
| 70 | url += "admins?setting=" + data.target.id |
||
| 71 | |||
| 72 | window.location.href = url |
||
| 73 | }) |
||
| 74 | } |
||
| 75 | }); |
||
| 76 | |||
| 82 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.